package cn.goktech.controller;

import cn.goktech.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/restful")
public class ResfulController {

    @RequestMapping(value = {"/user/{id}"}, method = {RequestMethod.GET})
    @ResponseBody
    public List<User> test(@PathVariable("id") String id, ModelAndView mv) {
        List<User> list = new ArrayList<User>();
        for (int i = 1; i <10 ; i++) {
            list.add(new User(i,"admin"+i,"宜宾"+i));
        }
        mv.addObject("list",list);
        mv.setViewName("success");
        return list;
    }
}
